package com.wangxiaotao.springcloud.alibaba.controller;

import com.wangxiaotao.springcloud.entities.CommonResult;
import com.wangxiaotao.springcloud.entities.Payment;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;

@RestController
public class PaymentController {
    public static HashMap<Long, Payment> hashMap = new HashMap<>();
    static {
        hashMap.put(1L,new Payment(1L,"897845512657486"));
        hashMap.put(2L,new Payment(1L,"rtggsdffesfsfde"));
        hashMap.put(3L,new Payment(1L,"09725yhtyutr576"));
    }

    @Value("$server.port")
    private String serverPort;

    @GetMapping(value = "/paymentSQL/{id}")
    public CommonResult<Payment> getPayment(@PathVariable("id")Long id){
        Payment payment = hashMap.get(id);
        return new CommonResult<>(200,"from mySQL,serverPort:"+serverPort,payment);
    }
}
